﻿// Fill out your copyright notice in the Description page of Project Settings.


#include "Core/PJGameInstance.h"

#include "Kismet/GameplayStatics.h"

void UPJGameInstance::SetHP(int NewHP)
{
	PlayerHP = NewHP;
}

void UPJGameInstance::AddDiamond(int Amount)
{
	DiamondCount += Amount;
}

void UPJGameInstance::ChangeLevel(int Level)
{
	if (Level < 1) return;
	CurrentLevelIndex = Level;

	const FString LevelNameString = FString::Printf(TEXT("Level_%d"), CurrentLevelIndex);
	UGameplayStatics::OpenLevel(GetWorld(), FName(LevelNameString));
}

void UPJGameInstance::RestartGame()
{
	PlayerHP = 100;
	DiamondCount = 0;
	IsDoubleJumpUnlock = false;
	
	CurrentLevelIndex = 1;
	ChangeLevel(CurrentLevelIndex);
}
